package com.feedback.a;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.feedback.b.a;
import com.feedback.b.b;
import com.feedback.b.d;
import com.feedback.b.e;
import com.feedback.c.c;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class c extends Thread
{
  private static ExecutorService b = Executors.newFixedThreadPool(3);
  private Context a;

  public c(Context paramContext)
  {
    this.a = paramContext;
  }

  public void run()
  {
    label36: String str1;
    Iterator localIterator2;
    int i;
    ArrayList localArrayList = new ArrayList();
    SharedPreferences localSharedPreferences = this.a.getSharedPreferences("feedback", 0);
    Iterator localIterator1 = localSharedPreferences.getAll().keySet().iterator();
    do
    {
      if (!(localIterator1.hasNext()))
      {
        localIterator2 = localArrayList.iterator();
        i = 0;
        if (localIterator2.hasNext())
          break;
        if (i != 0)
        {
          Intent localIntent = new Intent().setAction("postFeedbackFinished");
          this.a.sendBroadcast(localIntent);
        }
        return;
      }
      str1 = localSharedPreferences.getString((String)localIterator1.next(), null);
    }
    while ((com.feedback.c.c.a(str1)) || (str1.indexOf("fail") == -1));
    try
    {
      localArrayList.add(new com.feedback.b.b(new JSONArray(str1)));
    }
    catch (Exception localException)
    {
      com.feedback.b.b localb;
      d locald;
      do
      {
        break label36:
        localb = (com.feedback.b.b)localIterator2.next();
      }
      while ((localb.b == a.d) || (localb.b == a.a));
      Iterator localIterator3 = localb.f.iterator();
      int j = i;
      int k = -1;
      do
      {
        while (!(localIterator3.hasNext()))
          i = j;
        locald = (d)localIterator3.next();
        ++k;
      }
      while (locald.g != e.b);
      String str2 = localSharedPreferences.getString(localb.c, null);
      try
      {
        b localb1;
        do
        {
          JSONArray localJSONArray = new JSONArray(str2);
          localJSONArray.put(k, locald.h.put("state", e.d));
          localSharedPreferences.edit().putString(localb.c, localJSONArray.toString()).commit();
          localb1 = new b(locald.h, this.a);
        }
        while (localb1 == null);
        b.submit(localb1);
        j = 1;
      }
      catch (JSONException localJSONException)
      {
      }
    }
  }
}